extends AnimatedSprite2D


var status = 'idle'
@onready var hook = $'hook'
var hook_rad = 0
var hook_speed = 2
var degree = 0
var hook_init_position

# Called when the node enters the scene tree for the first time.
func _ready():
	#sprite_frames.set_animation_loop("drop", false)
	play("idle")
	hook_init_position = $hook.position


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if status == 'idle':
		play('idle')
		hook_rad += delta
		if hook_rad > 360:
			hook_rad = 0
		degree = sin(hook_rad)
		hook.rotation = degree
	elif status == 'drop':
		$hook.position += Vector2(0, hook_speed).rotated(degree)
	elif status == 'pull':
		$hook.position -= Vector2(0, hook_speed).rotated(degree)
		if $hook.position.y - hook_init_position.y < 0.1:
			status = 'idle'
			$hook.position = hook_init_position
	
	if Input.is_action_pressed("drop_hook") and status == 'idle':
		status = 'drop'
		play("drop")
	if Input.is_action_pressed("pull_hook") and status == 'drop':
		status = 'pull'
		play("pull")
